package com.iplant.ams.service.po.dms.scada.status;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.ams.service.basicenum.dms.scada.DMSDeviceStatusEnum;
import com.iplant.base.po.BasePO;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.base.utils.annotation.join.multi.DBJoinMulti;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.base.utils.general.CalendarTool;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;


public class DMSDeviceStatus implements Serializable {
    private static final long serialVersionUID = 1L;

    public int ID = 0;
    /**
    /// 设备编码
    */

    public String DeviceNo = "";


    public int DeviceID = 0;
    public String DeviceIP = "";
    /**
    ///  设备名称
    */

    public String DeviceName = "";

    /** 
    /// 固定资产编码  采集编码
    */

    public String AssetNo = "";
    /**
    /// 设备型号ID
    */
    public int ModelID = 0;
    /**
    /// 设备型号名称
    */
    public String ModelName = "";
    /**
    /// 设备型号ID
    */
    public String ModelNo = "";


    public int TeamID = 0;

    public String TeamNo = "";

    public String TeamName = "";

    public String Remark = "";

    /**
    /// 设备类型编码
    */
    public int DeviceType = 0;

    /**
    /// 设备类型名称
    */
    public String DeviceTypeName = "";
    /**
    /// 设备类型编码
    */
    public String DeviceTypeCode = "";


    public int FactoryID = 0;

    public String FactoryName = "";
    public String FactoryCode = "";

    /**
    /// 车间ID
    */
    public int WorkShopID = 0;

    public String WorkShopName = "";
    public String WorkShopCode = "";
    /**
    /// 产线ID
    */
    public int LineID = 0;

    public String LineName = "";
    public String LineCode = "";

    public int AreaID = 0;


    public String AreaNo = "";
    /**
    /// 位置信息
    */
    public String PositionText = "";

    public String ImageIcon = "";
    /**
    /// 当前状态
    */

    public int Status = 0;
    public int IsPlan = 0;
    /**
    /// 历史状态的显示状态
    */
    public int ActStatus = 0;


    /**
    /// 历史状态
    */

    public int StatusHistory = 0;

    /**
    /// 状态改变时刻
    */

    public Calendar StatusTime = CalendarTool.getCalendar(2000, 0, 1);

    /**
    /// 状态持续时长
    */

    public int Duration = 0;

    /**
    /// 状态结束时刻
    */

    public Calendar StatusTimeEnd = CalendarTool.getCalendar(2000, 0, 1);

    public int AlarmCount = 0;

    /**
    /// 是否当前状态
    */ 
    public int Active = 0;


    public List<String> WorkpieceNoList = new ArrayList<String>();


    public DMSDeviceStatus() {
    }

    public DMSDeviceStatus(DMSDeviceStatus wDMSDeviceStatus) {
        DeviceNo = wDMSDeviceStatus.DeviceNo;


        DeviceID = wDMSDeviceStatus.DeviceID;

        DeviceName = wDMSDeviceStatus.DeviceName;


        AssetNo = wDMSDeviceStatus.AssetNo;

        ModelID = wDMSDeviceStatus.ModelID;
        ModelName = wDMSDeviceStatus.ModelName;


        ModelNo = wDMSDeviceStatus.ModelName;


        TeamID = wDMSDeviceStatus.TeamID;

        TeamNo = wDMSDeviceStatus.TeamNo;

        TeamName = wDMSDeviceStatus.TeamName;

        Remark = wDMSDeviceStatus.Remark;

        DeviceType = wDMSDeviceStatus.DeviceType;

        DeviceTypeName = wDMSDeviceStatus.DeviceTypeName;
        DeviceTypeCode = wDMSDeviceStatus.DeviceTypeCode;


        FactoryID = wDMSDeviceStatus.FactoryID;

        FactoryName = wDMSDeviceStatus.FactoryName;
        FactoryCode = wDMSDeviceStatus.FactoryCode;


        WorkShopID = wDMSDeviceStatus.WorkShopID;

        WorkShopName = wDMSDeviceStatus.WorkShopName;
        WorkShopCode = wDMSDeviceStatus.WorkShopCode;


        LineID = wDMSDeviceStatus.LineID;

        LineName = wDMSDeviceStatus.LineName;
        LineCode = wDMSDeviceStatus.LineCode;

        AreaID = wDMSDeviceStatus.AreaID;

        AreaNo = wDMSDeviceStatus.AreaNo;


        PositionText = wDMSDeviceStatus.PositionText;

        ImageIcon = wDMSDeviceStatus.ImageIcon;


        Status = wDMSDeviceStatus.Status;

        StatusHistory = wDMSDeviceStatus.StatusHistory;

        StatusTime = wDMSDeviceStatus.StatusTime;

        Duration = wDMSDeviceStatus.Duration;

        StatusTimeEnd = wDMSDeviceStatus.StatusTimeEnd;

        AlarmCount = wDMSDeviceStatus.AlarmCount;


    }

    public DMSDeviceStatus Clone() {
        DMSDeviceStatus wDMSDeviceStatus = new DMSDeviceStatus();
        wDMSDeviceStatus.DeviceNo = this.DeviceNo;
        wDMSDeviceStatus.DeviceID = this.DeviceID;
        wDMSDeviceStatus.DeviceName = this.DeviceName;
        wDMSDeviceStatus.AssetNo = this.AssetNo;
        wDMSDeviceStatus.ModelID = this.ModelID;
        wDMSDeviceStatus.ModelName = this.ModelName;
        wDMSDeviceStatus.ModelNo = this.ModelName;
        wDMSDeviceStatus.TeamID = this.TeamID;
        wDMSDeviceStatus.TeamNo = this.TeamNo;
        wDMSDeviceStatus.TeamName = this.TeamName;
        wDMSDeviceStatus.Remark = this.Remark;
        wDMSDeviceStatus.DeviceType = this.DeviceType;
        wDMSDeviceStatus.DeviceTypeName = this.DeviceTypeName;
        wDMSDeviceStatus.DeviceTypeCode = this.DeviceTypeCode;
        wDMSDeviceStatus.FactoryID = this.FactoryID;
        wDMSDeviceStatus.FactoryName = this.FactoryName;
        wDMSDeviceStatus.FactoryCode = this.FactoryCode;
        wDMSDeviceStatus.WorkShopID = this.WorkShopID;
        wDMSDeviceStatus.WorkShopName = this.WorkShopName;
        wDMSDeviceStatus.WorkShopCode = this.WorkShopCode;
        wDMSDeviceStatus.LineID = this.LineID;
        wDMSDeviceStatus.LineName = this.LineName;
        wDMSDeviceStatus.LineCode = this.LineCode;
        wDMSDeviceStatus.AreaID = this.AreaID;
        wDMSDeviceStatus.AreaNo = this.AreaNo;
        wDMSDeviceStatus.PositionText = this.PositionText;
        wDMSDeviceStatus.ImageIcon = this.ImageIcon;
        wDMSDeviceStatus.Status = this.Status;
        wDMSDeviceStatus.StatusHistory = this.StatusHistory;
        wDMSDeviceStatus.StatusTime = this.StatusTime;
        wDMSDeviceStatus.Duration = this.Duration;
        wDMSDeviceStatus.StatusTimeEnd = this.StatusTimeEnd;
        wDMSDeviceStatus.AlarmCount = this.AlarmCount;

        return wDMSDeviceStatus;

    }


    @JsonProperty("ID")
    public int getID() {
        return ID;
    }

    public void setID(int ID) {
        this.ID = ID;
    }

    @JsonProperty("DeviceNo")
    public String getDeviceNo() {
        return DeviceNo;
    }

    public void setDeviceNo(String deviceNo) {
        DeviceNo = deviceNo;
    }

    @JsonProperty("DeviceID")
    public int getDeviceID() {
        return DeviceID;
    }

    public void setDeviceID(int deviceID) {
        DeviceID = deviceID;
    }

    @JsonProperty("DeviceIP")
    public String getDeviceIP() {
        return DeviceIP;
    }

    public void setDeviceIP(String deviceIP) {
        DeviceIP = deviceIP;
    }

    @JsonProperty("DeviceName")
    public String getDeviceName() {
        return DeviceName;
    }

    public void setDeviceName(String deviceName) {
        DeviceName = deviceName;
    }

    @JsonProperty("AssetNo")
    public String getAssetNo() {
        return AssetNo;
    }

    public void setAssetNo(String assetNo) {
        AssetNo = assetNo;
    }

    @JsonProperty("ModelID")
    public int getModelID() {
        return ModelID;
    }

    public void setModelID(int modelID) {
        ModelID = modelID;
    }

    @JsonProperty("ModelName")
    public String getModelName() {
        return ModelName;
    }

    public void setModelName(String modelName) {
        ModelName = modelName;
    }

    @JsonProperty("ModelNo")
    public String getModelNo() {
        return ModelNo;
    }

    public void setModelNo(String modelNo) {
        ModelNo = modelNo;
    }

    @JsonProperty("TeamID")
    public int getTeamID() {
        return TeamID;
    }

    public void setTeamID(int teamID) {
        TeamID = teamID;
    }

    @JsonProperty("TeamNo")
    public String getTeamNo() {
        return TeamNo;
    }

    public void setTeamNo(String teamNo) {
        TeamNo = teamNo;
    }

    @JsonProperty("TeamName")
    public String getTeamName() {
        return TeamName;
    }

    public void setTeamName(String teamName) {
        TeamName = teamName;
    }

    @JsonProperty("Remark")
    public String getRemark() {
        return Remark;
    }

    public void setRemark(String remark) {
        Remark = remark;
    }

    @JsonProperty("DeviceType")
    public int getDeviceType() {
        return DeviceType;
    }

    public void setDeviceType(int deviceType) {
        DeviceType = deviceType;
    }

    @JsonProperty("DeviceTypeName")
    public String getDeviceTypeName() {
        return DeviceTypeName;
    }

    public void setDeviceTypeName(String deviceTypeName) {
        DeviceTypeName = deviceTypeName;
    }

    @JsonProperty("DeviceTypeCode")
    public String getDeviceTypeCode() {
        return DeviceTypeCode;
    }

    public void setDeviceTypeCode(String deviceTypeCode) {
        DeviceTypeCode = deviceTypeCode;
    }

    @JsonProperty("FactoryID")
    public int getFactoryID() {
        return FactoryID;
    }

    public void setFactoryID(int factoryID) {
        FactoryID = factoryID;
    }

    @JsonProperty("FactoryName")
    public String getFactoryName() {
        return FactoryName;
    }

    public void setFactoryName(String factoryName) {
        FactoryName = factoryName;
    }

    @JsonProperty("FactoryCode")
    public String getFactoryCode() {
        return FactoryCode;
    }

    public void setFactoryCode(String factoryCode) {
        FactoryCode = factoryCode;
    }

    @JsonProperty("WorkShopID")
    public int getWorkShopID() {
        return WorkShopID;
    }

    public void setWorkShopID(int workShopID) {
        WorkShopID = workShopID;
    }

    @JsonProperty("WorkShopName")
    public String getWorkShopName() {
        return WorkShopName;
    }

    public void setWorkShopName(String workShopName) {
        WorkShopName = workShopName;
    }

    @JsonProperty("WorkShopCode")
    public String getWorkShopCode() {
        return WorkShopCode;
    }

    public void setWorkShopCode(String workShopCode) {
        WorkShopCode = workShopCode;
    }

    @JsonProperty("LineID")
    public int getLineID() {
        return LineID;
    }

    public void setLineID(int lineID) {
        LineID = lineID;
    }

    @JsonProperty("LineName")
    public String getLineName() {
        return LineName;
    }

    public void setLineName(String lineName) {
        LineName = lineName;
    }

    @JsonProperty("LineCode")
    public String getLineCode() {
        return LineCode;
    }

    public void setLineCode(String lineCode) {
        LineCode = lineCode;
    }

    @JsonProperty("AreaID")
    public int getAreaID() {
        return AreaID;
    }

    public void setAreaID(int areaID) {
        AreaID = areaID;
    }

    @JsonProperty("AreaNo")
    public String getAreaNo() {
        return AreaNo;
    }

    public void setAreaNo(String areaNo) {
        AreaNo = areaNo;
    }

    @JsonProperty("PositionText")
    public String getPositionText() {
        return PositionText;
    }

    public void setPositionText(String positionText) {
        PositionText = positionText;
    }

    @JsonProperty("ImageIcon")
    public String getImageIcon() {
        return ImageIcon;
    }

    public void setImageIcon(String imageIcon) {
        ImageIcon = imageIcon;
    }

    @JsonProperty("Status")
    public int getStatus() {
        return Status;
    }

    public void setStatus(int status) {
        Status = status;
    }

    @JsonProperty("IsPlan")
    public int getIsPlan() {
        return IsPlan;
    }

    public void setIsPlan(int isPlan) {
        IsPlan = isPlan;
    }

    @JsonProperty("ActStatus")
    public int getActStatus() {
        if ((Status & DMSDeviceStatusEnum.TurnOn.getValue()) == 0) {
            ActStatus = 0;
        } else if ((Status & (DMSDeviceStatusEnum.Run.getValue())) > 0) {
            ActStatus = DMSDeviceStatusEnum.Run.getValue();
        } else if ((Status & (DMSDeviceStatusEnum.EmergencyStop.getValue())) > 0) {
            ActStatus = DMSDeviceStatusEnum.EmergencyStop.getValue();
        } else if ((Status & (DMSDeviceStatusEnum.Alarm.getValue())) > 0) {
            ActStatus = DMSDeviceStatusEnum.Alarm.getValue();
        } else if ((Status & (DMSDeviceStatusEnum.Stop.getValue())) > 0) {
            ActStatus = DMSDeviceStatusEnum.Stop.getValue();
        } else if ((Status & (DMSDeviceStatusEnum.Manual.getValue())) > 0) {
            ActStatus = DMSDeviceStatusEnum.Manual.getValue();
        } else if ((Status & (DMSDeviceStatusEnum.Auto.getValue())) > 0) {
            ActStatus = DMSDeviceStatusEnum.Auto.getValue();
        } else if ((Status & (DMSDeviceStatusEnum.Wait.getValue())) > 0) {
            ActStatus = DMSDeviceStatusEnum.Wait.getValue();
        } else if ((Status & (DMSDeviceStatusEnum.TurnOn.getValue())) > 0) {
            ActStatus = (DMSDeviceStatusEnum.TurnOn.getValue());
        } else {
            ActStatus = 0;
        }
        return ActStatus;
    }

    public void setActStatus(int actStatus) {
        ActStatus = actStatus;
    }

    @JsonProperty("StatusHistory")
    public int getStatusHistory() {
        return StatusHistory;
    }

    public void setStatusHistory(int statusHistory) {
        StatusHistory = statusHistory;
    }

    @JsonProperty("StatusTime")
    public Calendar getStatusTime() {
        return StatusTime;
    }

    public void setStatusTime(Calendar statusTime) {
        StatusTime = statusTime;
    }

    @JsonProperty("Duration")
    public int getDuration() {
        return Duration;
    }

    public void setDuration(int duration) {
        Duration = duration;
    }

    @JsonProperty("StatusTimeEnd")
    public Calendar getStatusTimeEnd() {
        return StatusTimeEnd;
    }

    public void setStatusTimeEnd(Calendar statusTimeEnd) {
        StatusTimeEnd = statusTimeEnd;
    }

    @JsonProperty("AlarmCount")
    public int getAlarmCount() {
        return AlarmCount;
    }

    public void setAlarmCount(int alarmCount) {
        AlarmCount = alarmCount;
    }

    @JsonProperty("Active")
    public int getActive() {
        return Active;
    }

    public void setActive(int active) {
        Active = active;
    }

    @JsonProperty("WorkpieceNoList")
    public List<String> getWorkpieceNoList() {
        return WorkpieceNoList;
    }

    public void setWorkpieceNoList(List<String> workpieceNoList) {
        WorkpieceNoList = workpieceNoList;
    }
}
